package com.walle.common.result;

import com.alibaba.fastjson.JSON;

/**
 * <p>
 * Description： 服务返回提示信息
 * <p>
 * Author: FanSZ. Derek
 * <p>
 * Date: Created in 2018/4/3 15:20
 * <p>
 * Company:
 * <p>
 * Copyright: Copyright (c) 2017
 * <p>
 * Version: 1.0.0
 * <p>
 * Modified By:
 */

public class ResultResponseLu {
    public static final String CODE_NOT_NULL = "编码不能为空";
    public static final String NAME_NOT_NUll = "名称不能为空";

    public ResultResponseLu() {
        this.code =  ResultStatusEnum.SUCCESS.getCode();
        this.msg =  ResultStatusEnum.SUCCESS.getMessage();
        this.data = null;
    }
    public ResultResponseLu(int code, String message, Object data, int count) {
        this.code = code;
        this.msg = message;
        this.data = data;
        this.count = count;
    }

    public ResultResponseLu(Object data, int count) {
        this.code =  ResultStatusEnum.SUCCESS.getCode();
        this.msg =  ResultStatusEnum.SUCCESS.getMessage();
        this.data = data;
        this.count = count;
    }

    public static ResultResponseLu ofSuccess(){
        return new ResultResponseLu();
    }
    public static ResultResponseLu ofSuccess(Object data, int count){
        return new ResultResponseLu(data, count);
    }
    public static ResultResponseLu ofMessage(int code, String message){
        return new ResultResponseLu(code, message,null,0);
    }
    public static ResultResponseLu ofMessage(int code, String message, Object data){
        return new ResultResponseLu(code, message,data,0);
    }
    public static ResultResponseLu ofError(String message){
        return new ResultResponseLu(ResultStatusEnum.ERROR.getCode(), message,null,0);
    }


    /**
     *  编号
     */
    private int code;
    /**
     * 提示信息
     */
    private String msg;

    private int count = 0;
    private Object data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


}
